package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GaUserExam;
import com.ruoyi.system.service.IGaUserExamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生考试信息查询Controller
 * 
 * @author wzp
 * @date 2021-11-18
 */
@RestController
@RequestMapping("/kyga/userExam")
public class GaUserExamController extends BaseController
{
    @Autowired
    private IGaUserExamService gaUserExamService;

    /**
     * 查询学生考试信息查询列表
     */
    @PreAuthorize("@ss.hasPermi('kyga:userExam:list')")
    @GetMapping("/list")
    public TableDataInfo list(GaUserExam gaUserExam)
    {
        startPage();
        List<GaUserExam> list = gaUserExamService.selectGaUserExamList(gaUserExam);
        return getDataTable(list);
    }

    /**
     * 导出学生考试信息查询列表
     */
    @PreAuthorize("@ss.hasPermi('kyga:userExam:export')")
    @Log(title = "学生考试信息查询", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GaUserExam gaUserExam)
    {
        List<GaUserExam> list = gaUserExamService.selectGaUserExamList(gaUserExam);
        ExcelUtil<GaUserExam> util = new ExcelUtil<GaUserExam>(GaUserExam.class);
        return util.exportExcel(list, "学生考试信息查询数据");
    }

    /**
     * 获取学生考试信息查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('kyga:userExam:query')")
    @GetMapping(value = "/{examPaper}")
    public AjaxResult getInfo(@PathVariable("examPaper") Long examPaper)
    {
        return AjaxResult.success(gaUserExamService.selectGaUserExamByExamPaper(examPaper));
    }

    /**
     * 新增学生考试信息查询
     */
    @PreAuthorize("@ss.hasPermi('kyga:userExam:add')")
    @Log(title = "学生考试信息查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GaUserExam gaUserExam)
    {
        return toAjax(gaUserExamService.insertGaUserExam(gaUserExam));
    }

    /**
     * 修改学生考试信息查询
     */
    @PreAuthorize("@ss.hasPermi('kyga:userExam:edit')")
    @Log(title = "学生考试信息查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GaUserExam gaUserExam)
    {
        return toAjax(gaUserExamService.updateGaUserExam(gaUserExam));
    }

    /**
     * 删除学生考试信息查询
     */
    @PreAuthorize("@ss.hasPermi('kyga:userExam:remove')")
    @Log(title = "学生考试信息查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examPapers}")
    public AjaxResult remove(@PathVariable Long[] examPapers)
    {
        return toAjax(gaUserExamService.deleteGaUserExamByExamPapers(examPapers));
    }
}
